//package com.lab303.powerproject.strategy.service;
//
//import com.lab303.powerproject.strategy.WorkStrategyInterface;
//import com.lab303.powerproject.strategy.enums.StrategyEnums;
//import com.lab303.powerproject.strategy.impl.ComfortPriorityStrategy;
//import com.lab303.powerproject.strategy.impl.EconomicPriorityStrategy;
//import com.lab303.powerproject.strategy.impl.EnergySavingPriorityStrategy;
//import com.lab303.powerproject.strategy.utils.DateUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Service;
//
//import java.io.IOException;
//import java.text.ParseException;
//import java.util.Date;
//import java.util.Map;
//
//@Service
//public class StrategyGenerateService {
//    @Autowired
//    private EconomicPriorityStrategy economicPriorityStrategy;  // 经济优先工况生成器
//
//    @Autowired
//    private EnergySavingPriorityStrategy energySavingPriorityStrategy; // 节能优先工况生成器
//
//    @Autowired
//    private ComfortPriorityStrategy comfortPriorityStrategy; // 舒适度优先工况生成器
//
//    // 定时任务：每天 22:35 时进行三种类型的预测，并写入数据库
////    @Scheduled(cron = "0 35 22 * * ?")
//    public void timeTask() throws IOException, ParseException {
////        economicPriorityStrategy.save(DateUtils.plusOrMinusDay(new Date(), -1).getTime());
////        energySavingPriorityStrategy.save(DateUtils.plusOrMinusDay(new Date(), -1).getTime());
////        comfortPriorityStrategy.save(DateUtils.plusOrMinusDay(new Date(), -1).getTime());
//
//        economicPriorityStrategy.save(new Date());
//        energySavingPriorityStrategy.save(new Date());
//        comfortPriorityStrategy.save(new Date());
//    }
//
//    // 统一工况生成接口
//    private WorkStrategyInterface workStrategyInterface;
//
//    // 设置使用的工况生成类型
//    public void setWorkStrategyInterface(StrategyEnums strategyEnums) {
//        if (strategyEnums.getType().equals(StrategyEnums.ECONOMIC_TYPE.getType())) {
//            workStrategyInterface = economicPriorityStrategy;
//        }
//        if (strategyEnums.getType().equals(StrategyEnums.ENERGY_TYPE.getType())) {
//            workStrategyInterface = energySavingPriorityStrategy;
//        }
//        if (strategyEnums.getType().equals(StrategyEnums.COMFORT_TYPE.getType())) {
//            workStrategyInterface = comfortPriorityStrategy;
//        }
//    }
//
//    // 可以通过传入StrategyEnums的形式直接调用工况生成接口
//    public Map<String, Object> strategyGenerate(StrategyEnums strategyEnums, Date date) throws IOException,ParseException {
//        if (strategyEnums.getType().equals(StrategyEnums.ECONOMIC_TYPE.getType())) {
//            return economicPriorityStrategy.generate(date);
//        }
//        if (strategyEnums.getType().equals(StrategyEnums.ENERGY_TYPE.getType())) {
//            return energySavingPriorityStrategy.generate(date);
//        }
//        if (strategyEnums.getType().equals(StrategyEnums.COMFORT_TYPE.getType())) {
//            return comfortPriorityStrategy.generate(date);
//        }
//
//        // 如果传入了非上述给出策略的情况，返回null，表示暂不支持这种策略生成模式
//        return null;
//    }
//
//    // 也可以在调用setWorkStrategyInterface之后直接使用默认的工况生成接口
//    public Map<String, Object> strategyGenerate(Date date) throws IOException,ParseException {
//        if (workStrategyInterface != null) {
//            return workStrategyInterface.generate(date);
//        }
//        // 如果未设置工况生成接口，返回null
//        return null;
//    }
//}